//
//  device_retriever.h
//  testpcap
//
//  Created by bugforever on 1/10/15.
//  Copyright (c) 2015 bugforever. All rights reserved.
//

#ifndef __device_retriever_h
#define __device_retriever_h

#include <vector>

class device_info
{
public:
    device_info();
    ~device_info();
    
    void set_name(char * str_name);
    void set_friendlyname(char * str_friendlyname);
    void set_description(char * str_description);
    
    char * get_name();
    char * get_friendlyname();
    char * get_description();
    
    device_info& operator=( device_info& info );
    
private:
    void cpy_string(char ** ptr_str_dest, char * str_src);
    
private:
    char * m_str_name;
    char * m_str_friendlyname;
    char * m_str_description;
};

class interface_device_retriever
{
public:
    virtual ~interface_device_retriever(){};
    virtual bool get_device_list(std::vector< device_info * > ** pptr_list) = 0;
};


class device_retriever:
public interface_device_retriever
{
public:
    device_retriever();
    virtual ~device_retriever();
    
    virtual bool get_device_list(std::vector< device_info * > ** pptr_list);
    
private:
    interface_device_retriever * m_ptr_retriever;
};

template < class T >
void destroy_vector(std::vector< T * >& vector_list)
{
    typename std::vector< T * >::iterator iter = vector_list.begin();
    typename std::vector< T * >::iterator itere = vector_list.end();
    
    while (iter != itere)
    {
        delete *iter;
        iter++;
    }
}


#endif /* defined(__testpcap__device_retriever__) */
